
/**
 * Created by Will Bean on 2016/7/24.
 */
import React, { Component,PropTypes } from 'react'

import style from './addStore.css'

class ImageWithState extends Component{
    constructor(props){
        super(props);
        this.state = {
            stateMsg : this.props.stateMsg ? this.props.stateMsg : '',
            deleteBtn : this.props.deleteBtn ? this.props.deleteBtn : false
        }
    }

    render(){
        const { src , id, liClassName, imgClassName } = this.props;
        return (
            <li key={id} className={liClassName}>
                <img src={src} className={imgClassName}/>
                {this.props.stateMsg == '保存成功' ? <strong className={style["save_true"]}>{this.props.stateMsg}</strong> :
                this.props.stateMsg == '保存失败' ?  <strong className={style["save_error"]}>{this.props.stateMsg}</strong> : null
                }
                {this.state.deleteBtn ? <span key={'sp'+id} onClick={this.props.onClick} className={style['delete']}>删除</span> : null }
            </li>
        )
    }
}

export default ImageWithState;